<?php
session_start();
/**
 * interface.php
 * 
 * The interface.php file contains functions that print the redundant HTML elements of a webpage.
 */

/**
 * Prints the HTML doctype, the <html> start tag, and the <head> start tag.
 */
function webpageDoctype() {
	echo <<<EOL
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
EOL;
}

/**
 * Prints the <meta> tags, CSS stylesheet link, the baginning of the <body> area.
 */
function webpageMetaAndBodyStart() {
	echo <<<EOL
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
	<div id="background">
	<a name="top"></a>
	</div>
	
	<div id="header">
	<img src="hyperlinks logo.png" width="300" />
	</div>
	<div id="navBar">
EOL;
	// If a user is logged in display the homepage and my account linka.
	if (strlen($_SESSION['username']) > 0 && strlen($_SESSION['userid']) > 0) {
		echo <<<EOL
		<a href="./member.php" class="nav">Home</a>
		<a href="./my_account.php" class="nav">My Account</a>
EOL;
	}
	if (strlen($_SESSION['username']) <= 0 && strlen($_SESSION['userid']) <= 0) {
		echo <<<EOL
		<a href="./login.php" class="nav">Login</a>
EOL;
	}
	if (strlen($_SESSION['username']) > 0 && strlen($_SESSION['userid']) > 0) {
		echo <<<EOL
		<a href="./logout.php" class="nav">Logout</a>
EOL;
	}
	echo <<<EOL
	<a href="./register.php" class="nav">Register</a>
EOL;
	// If a user is logged in display the user preferences link.
	if (strlen($_SESSION['username']) > 0) {
		echo <<<EOL
		<a href="./userpreference.php" class="nav">User Preferences</a>
EOL;
	}
	echo <<<EOL
	<a href="./forgotpass.php" class="nav">Forgot Password</a>
	</div>
	<div id="main">
EOL;
}

/**
 * Prints the closing <div> tags, <body> tag, and <html> tag.
 */
function webpageFooter() {
	echo <<<EOL
			</div>
		</div>
	</div>
</body>
</html>
EOL;
}

/**
 * This function prints the HTML title tag for each webpage.
 * 
 * @param string $title, the title of the webpage
 */
function print_html_title($title) {
	echo "<title>HyperLinks | $title</title>";
}
?>